<template>
	<view class="content" v-if="show==1">
		<view class="news">
			<navigator :url="'/pages/news/detail?id='+n.id" class="news2" v-for="n in news">
				
				<view class="news4">{{n.title}}</view>
				<view class="news5">
					<text>发布于{{n.createtime}}</text>
					<text class="liu">{{n.view}}人浏览</text>
				</view>
			</navigator>
		</view>
	</view>
</template>

<script>
	var app=getApp();
	export default {
		data() {
			return {
				show:0,
				news:[],
				page:1,
				next:0
			}
		},
		onLoad() {
			this.getdata();
		},
		methods: {
			getdata(){
				var that=this;
				uni.showLoading({
				    title: '数据加载中'
				});
				uni.request({
				    url: app.globalData.url+"index/news",
					method:"POST",
					dataType:"json",
					header: {
					    'content-type': 'application/x-www-form-urlencoded'
					},
				    data: {},
				    success: (res) => {
						uni.hideLoading();
						if(res.data.code!=1){
							app.error_msg(res.data.msg);
						}
						that.news=that.news.concat(res.data.data.news)
						that.next=res.data.data.next
						that.page++;
						that.show=1;
				    }
				});
			},
			tui(){
				uni.navigateBack({
				    delta: 1
				});
			},
			onReachBottom(){
				if(this.next==1){
					this.next=0;
					this.getdata();
				}
			}
		}
	}
</script>

<style>
	.liu{float: right;}
	.news5{width:94%;padding: 0px 3%;height:20px;line-height: 20px;color:#999;}
	.news4{width:94%;padding: 0px 3%;height:30px;line-height: 30px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;font-size: 0.9rem;}
	.news4 text{font-size: 0.7rem;color:#999;margin-right: 3px;}
	.news2{border-bottom: 1px #f7f6f7 solid;padding-bottom: 12px;padding-top: 5px;}
	.news{width:100%;margin-top: 10px;}
</style>
